package com.lesama.pool;

/*
Executors中提供静态方法来创建线程
    static ExecutorService newCachedThreadPool() 创建一个默认的线程池 最大数量INT_MAX
    static newFixedThreadPool(int nThreads) 创建一个指定最多线程数量的线程池
 */

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo1 {
    public static void main(String[] args) {
        ExecutorService threadPool = Executors.newCachedThreadPool();

        for (int i = 0; i < 100; i++) {
            threadPool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + "提交了任务");
                }
            });
        }
    }
}
